<template>
  <div>
    {{ count }}
    <button @click="count++">修改</button>
    <p>{{ person }}</p>
  </div>
</template>

<script lang="ts">
 import { defineComponent } from 'vue'
  export default  defineComponent({
    name:'App'
  })
</script>
<script lang="ts" setup>
  import {ref,watch} from 'vue'
  const count=ref(0)


  const person = ref({
  name: "xiaowang",
  age: 18,
  score: {
    ch: 100,
    math: 90,
  },
});

  //如果ref保存的是一个基本类型的话，我们直接监听当前ref对象即可得到值的改变
  watch(count,(newVal,oldVal)=>{
console.log(newVal,oldVal);


  })
</script>

<style lang="less" scoped>
  
</style>